﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Modelo;

namespace Interfaces
{
    /// <summary>
    /// Interaction logic for IUAgregarProducto.xaml
    /// </summary>
    public partial class IUAgregarProducto : Window
    {
        public IUAgregarProducto()
        {
            InitializeComponent();
            comboBox1.Items.Add("Unidad");
            comboBox1.Items.Add("Kg");
            comboBox1.Items.Add("cc");
            comboBox1.Items.Add("lt");
            comboBox1.Items.Add("oz");
            comboBox1.Items.Add("lb");
            comboBox1.Items.Add("Galones");
            comboBox1.SelectedIndex = 0;
        }

        private void agregarBtn_Click(object sender, RoutedEventArgs e)
        {
            
            try
            {
                string medida = comboBox1.SelectedItem.ToString();
                Producto product = Negocio.Validar.ValidarProducto(nombreTbx.Text, "0", medida, precioTbx.Text, detalleTbx.Text);
                if (product != null)
                    Negocio.ControladorProducto.AgregarProducto(product);
                this.Close();
            }
            catch (Exception ex)
            {

                errorLbl.Content= ex.Message;
            }
        }

        private void precioTbx_TextChanged(object sender, TextChangedEventArgs e)
        {

        }
    }
}
